﻿//-------------------------------------------赵洪科----------------------------------------------//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
///TurnOver 的摘要说明
/// </summary>
public partial class TurnOver
{
    DataTableDataContext db = new DataTableDataContext();
    //插入新项 ,并返回主码（日期）
    public DateTime insertTo(DateTime datetime, decimal pay, int num = 1)
    {
        TurnOver turnover = new TurnOver
        {
            date = datetime,
            orderMoney = pay,
            orderNumber = num,

        };
        db.TurnOver.InsertOnSubmit(turnover);
        db.SubmitChanges();
        DateTime d = turnover.date;
        return d;
    }

    //按主码（日期）查询
    public IEnumerable<TurnOver> returnFr(DateTime datetime)
    {
        var turnover = from b in db.TurnOver where b.date == datetime select b;
        return turnover;
    }

    //按主码删除某一记录
    public void removeFr(DateTime datetime)
    {
        var turnovers = from b in db.TurnOver where b.date == datetime select b;
        foreach (var turnover in turnovers)
        {
            db.TurnOver.DeleteOnSubmit(turnover);
            db.SubmitChanges();
        }
    }
}